home *** CD-ROM | disk | FTP | other *** search
- head 1.2;
- branch ;
- access ;
- symbols ;
- locks ; strict;
- comment @ * @;
-
-
- 1.2
- date 89.03.22.00.47.13; author rab; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 88.05.21.16.17.51; author ouster; state Exp;
- branches ;
- next ;
-
-
- desc
- @@
-
-
- 1.2
- log
- @*** empty log message ***
- @
- text
- @/*
- * getenv.c --
- *
- * Source code for the "getenv" library procedure.
- *
- * Copyright 1988 Regents of the University of California
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies. The University of California
- * makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without
- * express or implied warranty.
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: /sprite/src/lib/c/stdlib/RCS/getenv.c,v 1.1 88/05/21 16:17:51 ouster Exp Locker: rab $ SPRITE (Berkeley)";
- #endif /* not lint */
-
- #include <stdio.h>
- #include <stdlib.h>
-
- extern char **environ;
-
- /*
- *----------------------------------------------------------------------
- *
- * getenv --
- *
- * Locate an environment variable by a given name.
- *
- * Results:
- * The return value is a pointer to the value associated with
- * name, or 0 if there is no value registered for name. The return
- * value points into environment storage, which is only guaranteed
- * to persist until the next call to setenv.
- *
- * Side effects
- * None.
- *
- *----------------------------------------------------------------------
- */
-
- char *
- getenv(name)
- char *name; /* Name to retrieve value for. */
- {
- char **envPtr; /* pointer into list of environ. vars. */
- register char *charPtr; /* point into one environment variable */
- register char *namePtr; /* pointer into name */
-
- for (envPtr = environ; *envPtr != NULL; envPtr++) {
- for (charPtr = *envPtr, namePtr = name; *charPtr == *namePtr;
- charPtr++, namePtr++) {
- if (*charPtr == '=') {
- break;
- }
- }
- if ((*charPtr == '=') && (*namePtr == NULL)) {
- return charPtr+1;
- }
- }
- return NULL;
- }
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d17 2
- a18 2
- static char rcsid[] = "$Header: proto.c,v 1.2 88/03/11 08:39:08 ouster Exp $ SPRITE (Berkeley)";
- #endif not lint
- d20 3
- d52 1
- a52 1
- for (envPtr = environ; *envPtr != 0; envPtr++) {
- d59 1
- a59 1
- if ((*charPtr == '=') && (*namePtr == 0)) {
- d63 1
- a63 1
- return 0;
- @
-